#!/bin/bash

DEBUG=-g
CFLAGS="-I/proj/virtualrobotics/svn/src/robotslib/interfaces -I/proj/virtualrobotics/svn/src/common/ -I/usr/include/qt4/QtCore -I/usr/include/qt4"
MAKEFILE=makefile
echo "" > $MAKEFILE
#echo "" > $ROBOTSFILE
for f in `ls *.h`
do
	NAME=`echo $f | sed -r 's/^(.*)\.h$/\1/'`
	FACTORYFILE="$NAME.Factory.cpp"
	echo "Processing $f"
	echo "#include \"$f\""
	echo "Algorithm* createAlgorithm() {"
	echo "	return new $NAME();"
	echo "}"
	echo "$NAME.so: $NAME.h $NAME.cpp" >> $MAKEFILE
	echo "	g++ $DEBUG -fPIC -shared -Wl,-soname,$NAME $CFLAGS -o $NAME.so $NAME.h $NAME.cpp" >> $MAKEFILE
done
echo "all: %.so" >> $MAKEFILE
echo "clean:" >> $MAKEFILE
echo "	rm -f *.so" >> $MAKEFILE
echo "re: clean all" >> $MAKEFILE
echo ".PHONY: all clean re" >> $MAKEFILE
